// components/like/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    like: {
      type: Boolean
    },
    count: {
      type: Number
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    yesSrc: 'image/like.png',
    noSrc: 'image/dislike.png'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onLike (e) {
      // console.log(e)
      let like = this.properties.like,
          count = this.properties.count
      like = !like 
      // console.log(like)
      if(like) {
        count++
      } else count--
      this.setData({
        count: count,
        like: like
      })
      let behaviour = this.properties.like?'like':'dislike'
      // console.log(behaviour)
      this.triggerEvent('like', {behaviour},{})
    }
  }
})
